/*
 * Copyright (c) www.bugull.com
 */

package com.bugull.farm.app.server.processor;

import org.apache.log4j.*;

import com.bugull.farm.core.cache.PropertiesCache;
import com.bugull.farm.core.frame.structure.Frame;
import com.bugull.farm.core.handler.Processor;
import com.bugull.farm.core.utils.ByteUtil;
import io.netty.channel.ChannelHandlerContext;

/**
 * For command: CMD_APP_HEARTBEAT
 * 
 * @author Frank Wen(xbwen@hotmail.com)
 */
public class AppHeartbeatProcessor implements Processor {
	
	private PropertiesCache props = PropertiesCache.getInstance();
	
    @Override
    public void process(ChannelHandlerContext ctx, Frame frame) throws Exception{
    	//回复心跳
        byte[] intervalBytes = ByteUtil.fromShort((short)props.getInt("app.heartbeat.interval").intValue());
        frame.setBytes("interval", intervalBytes);
        ctx.writeAndFlush(frame.getFastResponse());
    }

}
